#ifndef TCPTUNNEL_H
#define TCPTUNNEL_H
#include <QObject>
#include "sslserver.h"
#include <QTcpSocket>
#define TCPTUNID 0x7FFFFFFF
#define TCPPORTNAME "TCP"
class tcpTunnel : public QObject
{
	Q_OBJECT
public:
	tcpTunnel(QObject * parent = nullptr);
protected:
	void timerEvent(QTimerEvent *event) override;
	//Tunnel
protected:
	SSLServer * m_svr = nullptr;
	QTcpSocket * m_sock = nullptr;
	QString m_str_addr = "127.0.0.1";
	int	m_n_port = 12373;
	bool m_bListen = false;
	bool m_bSSL = false;
	QByteArray m_package_array;
	int m_nTimer = -1;
	int m_nEmitter = -1;
	QTcpSocket::SocketState m_lastState = QTcpSocket::UnconnectedState;
private:
	quint64 m_nTPos = 0;
	quint64 m_total_caps = 0;
protected slots:
	void slot_read_sock();
	void slot_new_connection(qintptr socketDescriptor);
public slots:
	void startWork(QString address, QString port, bool listen,bool ssl);
	void stopWork();
signals:
	void sig_message(QString);
};

#endif // TCPTUNNEL_H
